home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 3
/
Amoszine 3.adf
/
MORE_SOURCE
/
F1Colourcode.AMOS.pp
/
F1Colourcode.AMOS
/
F1Colourcode.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1992-02-26
|
7KB
|
273 lines
' ******************************************
' * COLOURCODE by Dave King June 1993 *
' ******************************************
'
' A Version of the board game Mastermind
'
' ************************************************************************
' * *
' * Palette Colours : - *
' * *
' * 0 - Black 1 - Brown 2 - White 3 - Orange *
' * 4 - Red 5 - Green 6 - Blue 7 - Grey *
' * 8 - Dark Grey 9 - Yellow 10 - Mauve 11 - Dark Green *
' * 12 - Pink 13 - Dark Blue 14 - Light Grey 15 - Cyan *
' * *
' ************************************************************************
'
' ***********************************************************************
' * Variable list : - *
' * *
' * C() 1-4 The four Code Sequence Numbers *
' * P() 1-4 Copy of The four Code Sequence Numbers *
' * G() 1-4 The four Code Sequence Guessed *
' * C - Colour Indicator *
' * BC - Count of Correct Colours *
' * BLC - Count of Incorrect Colours *
' * GUESS - Number of Guesses Entered *
' * *
' ***********************************************************************
'
Screen Open 0,320,216,16,Lowres
Flash Off
Get Sprite Palette
For N=1 To 10 : No Mask N : Next N
Randomize Timer
Dim C(4),P(4),G(4)
BEGIN:
Paper 7 : Pen 2 : Cls
Curs Off
Gosub BOARD_DRAW
Gosub RANDOM_SELECT
C=0 : GO=1
'
' *** MAIN LOOP START *****************************
'
For Y=24 To 164 Step 15
Locate 7,23 : Paper 8 : Pen 9 : Print " Enter Guess Number";GO;" ? " : Paper 7 : Pen 2
Repeat
PASS=0
For X=151 To 211 Step 20
Paste Bob X,Y,1
Next X
GUESS=0
For X=151 To 211 Step 20
Clear Key
Wait 3 : K=0
GUESS=GUESS+1
If C=1 and GUESS>1 Then GUESS=GUESS-1
If C=1 Then X=X-20
If X<151 Then X=151
Limit Mouse 157,72 To 170,194
Do
K=0
A=X Mouse : B=Y Mouse
K=Mouse Key
If A>157 and A<170 and B>72 and B<84 and K=1 Then C=2 : Exit
If A>157 and A<170 and B>88 and B<98 and K=1 Then C=3 : Exit
If A>157 and A<170 and B>104 and B<114 and K=1 Then C=4 : Exit
If A>157 and A<170 and B>120 and B<130 and K=1 Then C=5 : Exit
If A>157 and A<170 and B>136 and B<146 and K=1 Then C=6 : Exit
If A>157 and A<170 and B>152 and B<162 and K=1 Then C=7 : Exit
If A>157 and A<170 and B>184 and B<194 and K=1 Then C=1 : Exit
Loop
If C=1 and GUESS>1 Then GUESS=GUESS-1 : Boom
If C=1 Then X=X-20
If X<151 Then X=151
Paste Bob X,Y,C
G(GUESS)=C
Wait 8
Next X
Wait 4 : K=0
Locate 7,23 : Pen 9 : Print " "
Limit Mouse 287,244 To 381,255
For N=24 To 30
Play 4,N,1
Next N
Ink 4,8 : Text 50,202," ENTER CODE "
Ink 10,2 : Text 160,202," Yes "
Ink 9,4 : Text 220,202," No "
X Mouse=337 : Y Mouse=249
Do
A=X Mouse : B=Y Mouse : K=Mouse Key
If K=1 and A<329 Then PASS=1 : Exit
If K=1 and A>348 Then Exit
Loop
Ink 7 : Bar 50,195 To 251,205
Until PASS=1
B$=""
Gosub INDICATE
If B$="y" Then Goto BEGIN
If B$="n" Then End
Wait 10 : GO=GO+1
Next Y
'
' ********* END OF MAIN LOOP ********************************
'
' *******************************
' * DRAW BOARD ROUTINE *
' *******************************
'
BOARD_DRAW:
Restore DATPRINT
DATPRINT:
Data "= White","= Orange","= Green","= Red","= Yellow","= Cyan"
BN=2 : B=24
For N=3 To 13 Step 2
Read C$
Paste Bob 31,B,BN : BN=BN+1
Locate 6,N : Print C$
B=B+16
Next N : Ink 2
Locate 3,17 : Print "( ) to Erase"
Box 146,4 To 262,172
Ink 0 : Bar 147,6 To 261,18
H$="COLOUR-CODE?"
X=0
Paper 0
For N=1 To 11
Do
LAST=X
X=Rnd(5)+2
If X=6 Then X=9
If X=7 Then X=15
If X<>LAST Then Exit
Loop
L$=Mid$(H$,N,1)
Locate 19+N,1
Pen X : Print L$
Next N : Pen 2
For X=151 To 214 Step 20
For Y=24 To 164 Step 15
Paste Bob X,Y,1
Next Y
Next X
For X=225 To 249 Step 8
For Y=24 To 164 Step 15
Paste Bob X,Y+1,8
Next Y
Next X
Ink 2 : Box 146,4 To 262,172
Paper 7
Return
'
' *******************************
' * PRINT INDICATORS ROUTINE *
' *******************************
'
INDICATE:
For N=1 To 4 : P(N)=C(N)
Next N
BC=0 : BLC=0
'
' *** INDICATE NUMBER RIGHT (BC) ***
'
For N=1 To 4
If G(N)=C(N) Then BC=BC+1 : C(N)=9
Next N
'
' *** INDICATE NUMBER WRONG (BLC) ***
'
For K=1 To 4
For N=1 To 4
If N<>K and G(K)=C(N) and G(K)<>P(K) Then BLC=BLC+1 : C(N)=9 : Exit
Next N
Next K
For N=1 To 4 : C(N)=P(N)
Next N
V=X-1 : Z=Y+4
Ink 0
For K=1 To BC
If BC=0 Then Exit
Circle V,Z+1,2 : Paint V,Z+1,0
Bell 35
V=V+8
Next K
If BC=4 Then Gosub GAME_WIN : Return
Ink 2
For K=1 To BLC
If BLC=0 Then Exit
Circle V,Z+1,2 : Paint V,Z+1,0
V=V+8
Bell 3
Next K
If GO=10 Then Gosub GAME_LOOSE
Return
'
' *******************************
' * RANDOM SELECT ROUTINE *
' *******************************
'
RANDOM_SELECT:
'
' RANDOMLY GENERATE COLOUR SEQUENCE
'
For N=1 To 4
J=Rnd(5)+2
C(N)=J
Next N
Return
'
' *******************************
' * WIN GAME ROUTINE *
' *******************************
'
GAME_WIN:
GO$=Str$(GO)
Locate 7,23 : Pen 9 : Print " "
Ink 2,0 : Text 30,170," WELL DONE "
For K=2 To 6 Step 2
For J=20+K*2 To 35+K*2 Step 5
For N=J+2 To J+21 Step 3
Play 1,N,1
Next N
Next J
Next K
M$=" Moves" : If GO=1 Then M$=" Move"
I$=GO$+M$
Ink 2,6 : Text 20,186," "
Ink 2,6 : Text 28,186,"You Broke the Code in "
Text 196,186,I$
Gosub ANOTHER_GAME
Return
'
' *******************************
' * LOOSE GAME ROUTINE *
' *******************************
'
GAME_LOOSE:
Locate 7,23 : Pen 9 : Print " "
Ink 2,0 : Text 22,170," YOU LOOSE! "
For N=10 To 3 Step -1
Play 4,N,6
Next N
Ink 9,7 : Text 3,186,"The Correct Code ="
For N=1 To 4
J=131+(N*20)
Paste Bob J,179,C(N)
Next N
Gosub ANOTHER_GAME
Return
'
' *******************************
' * PLAY AGAIN ROUTINE *
' *******************************
'
ANOTHER_GAME:
Wait 20
Ink 4,8 : Text 50,202," PLAY AGAIN "
Ink 10,2 : Text 160,202," Yes "
Ink 9,4 : Text 220,202," No "
Limit Mouse 287,244 To 381,255
CL=0
Do
B$=Inkey$
If B$="y" Then Exit
If B$="n" Then Exit
X=X Mouse
Y=Y Mouse
CL=Mouse Click
If CL=1 and X<329 Then B$="y" : Exit
If CL=1 and X>348 Then B$="n" : Exit
Loop
Return